import com.baomidou.mybatisplus.generator.FastAutoGenerator;
import com.baomidou.mybatisplus.generator.config.DataSourceConfig;
import com.baomidou.mybatisplus.generator.config.OutputFile;
import com.baomidou.mybatisplus.generator.engine.FreemarkerTemplateEngine;

import java.util.Collections;

public class MySQLGenerate {
    private final static String dbUrl = "jdbc:mysql://10.188.132.24:6606/KITDB" +
            "git config --global --add safe.directory E:/myworkspace/skycity/skycity-cloud" +
            "git config --global --add safe.directory E:/myworkspace/skycity/skycity-cloud" +
            "?characterEncoding=utf8&connectTimeout=1000&socketTimeout=3000&autoReconnect=true";
    private final static String driver = "com.mysql.cj.jdbc.Driver";
    private final static String userName = "root";
    private final static String password = "abcd-1234";

    public static void main(String[] args) {
        FastAutoGenerator.create(new DataSourceConfig.Builder(dbUrl, userName, password))
                .globalConfig(builder -> {
                    builder.author("YingBo.Dai")
                            .outputDir("E:\\workspace\\nacos_lemes\\lemes-cloud\\lemes-business-pcg\\lemes-service-kitting\\lemes-service-kitting-server\\src\\main\\java"); // 指定输出目录
                })
                .packageConfig(builder -> {
                    builder.parent("com.lenovo.lemes.service.kitting.server") // 设置父包名
//                            .moduleName("kitting.server") // 设置父包模块名
                            .pathInfo(Collections.singletonMap(OutputFile.xml, "E:\\workspace\\nacos_lemes\\lemes-cloud\\lemes-business-pcg\\lemes-service-kitting\\lemes-service-kitting-server\\src\\main\\java\\com\\lenovo\\lemes\\service\\kitting\\server\\dao")); // 设置mapperXml生成路径
                })
                .strategyConfig(builder -> {
                    builder.addInclude("SUPPLIER_PN_RELATION") // 设置需要生成的表名
                            .addTablePrefix("t_", "c_")
                            .controllerBuilder().enableRestStyle()
                            .mapperBuilder().enableMapperAnnotation()
//                            .entityBuilder()
                            .entityBuilder().enableLombok()
                    ; // 设置过滤表前缀
                })
                .templateEngine(new FreemarkerTemplateEngine()) // 使用Freemarker引擎模板，默认的是Velocity引擎模板
                .execute();
    }
}
